package com.sskj.app.config.interceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by Zhang on 2018/8/26.
 */
@Configuration
public class InterceptorConfig extends WebMvcConfigurerAdapter {
    @Bean
    public Appinterceptor appinterceptor() {
        return new Appinterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        //配置 不需要拦截的包和请求
   String[]excludePathPatterns=new String[]{
           "/stockUser/login",
           "/stockUser/insertUser",
           "/swagger-ui.html",
           "/swagger-resources/**",
           "/webjars/**",
           "/v2/**"
   };
        registry.addInterceptor(  appinterceptor()).addPathPatterns("/**").excludePathPatterns(excludePathPatterns);
    }


}
